package services;

import java.util.List;

import javax.inject.Inject;

import mappers.JourneyMapper;
import mappers.PositionsMapper;
import models.Journey;
import models.Point;

public class PointService {
	@Inject
    public PositionsMapper positionsMapper;
	
	public List<Point> getAllByUsername(String username){
        List<Point> points = positionsMapper.getAllByUsername(username);
        return points;
    }
	
	public List<Point> getPointsByUsername(String username){
        List<Point> points = positionsMapper.getAllByUsername(username);
        return points;
    }
	public  List<Point> getPointsByUserId(int user_id) {
		List<Point> points = positionsMapper.getAllByUserId(user_id);
        return points;
	}
	public  List<Point> getSharePointsByUserId(int position_id) {
		List<Point> points = positionsMapper.getShareByUserId(position_id);
        return points;
	}
	public List<Point> loadPhoto(String username){
        List<Point> points = positionsMapper.loadPhoto(username);
        return points;
    }
	
	public void insertPoint(Point point) {
		positionsMapper.insertCoordinate(point);
		positionsMapper.insertPoint(point);
	}
	public List<Point> getPoint(int position_id) {
        List<Point> point = positionsMapper.getPoint(position_id);
        return point;
    }
	public List<Point> point_photo(int position_id) {
        List<Point> point = positionsMapper.point_photo(position_id);
        return point;
    }
	public void updatePoint(Point point) {
		positionsMapper.updateCoordinate(point);
		positionsMapper.updatePoint(point);
	}
	
	public void remove(Point point) {
		positionsMapper.deleteCoordinate(point);
		positionsMapper.deletePoint(point);
		positionsMapper.deleteMedia(point);
	}

	public void insertUrl(models.Point point) {
		positionsMapper.updatePoint(point);
		Point pos =  positionsMapper.getPosition(point.getPosition_id());
		pos.setLink(point.getLink());
		positionsMapper.insertUrl(pos);
		positionsMapper.updateName(point);
	}
	
}
